import Vue from "vue";
import Router from "vue-router";
import Aside from "../pages/Aside";
import store from "../store/index";
import { Message, Notification } from "element-ui";
import NewUser from "../pages/NewUser.vue";
import Apply from "../pages/Apply.vue";
import NewUserRequest from '../pages/NewUserRequest.vue';
import NewUserNormal from '../pages/NewUserNormal.vue';
import NewUserAdmin from '../pages/NewUserAdmin.vue';
import Route from '../pages/Route3.vue';
import TaskVue from '../pages/Task.vue';
import realtimeVue from '../pages/RealTime.vue';
import Replay from '../pages/Replay.vue';
import DataManipulation from '../pages/dataManipulation.vue';
import DeviceDetail from '../pages/DeviceDetail.vue';
import home from "../pages/home";
import login from "../pages/login";
import View from "../pages/View";
import Logger from "../pages/Logger";

Vue.use(Router);

export const asyncRoutes = [
    {
        path: "/",
        redirect: "/login",
    },
    {
        path: "/login",
        name: "login",
        meta: {
            name: "登录"
        },
        component: login
    },
    {
        path: "/home",
        name: "home",
        meta: {
            name: "首页",
        },
        component: home,
        children: [
            {
                path: 'view',
                name: 'view',
                component: View
            },
            {
                path: 'detail',
                name: 'detail',
                component: DeviceDetail,
                // children: [
                //      {
                //          path: '/deviceapply',
                //          name: 'deviceapply',
                //          component: DeviceApplyVue
                //      },
                //     {
                //         path: '/devicetotal',
                //         name: 'devicetotal',
                //         component: DeviceTotalVue
                //     },
                //     {
                //         path: '/deviceDetail',
                //         name: 'deviceDetail',
                //         component: deviceDetail
                //     }
                // ]
            },
            {
                path: 'route',
                name: 'route',
                component: Route
            },
            {
                path: 'dataManipulation',
                name: 'dataManipulation',
                component: DataManipulation
            },
            {
                path: 'task',
                name: 'task',
                component: TaskVue
            },
            {
                path: 'userApply',
                name: 'userApply',
                component: NewUserRequest
            },
            {
                path: 'userAuth',
                name: 'userAuth',
                component: NewUserNormal
            },
            {
                path: 'userAdd',
                name: 'userAdd',
                component: NewUserAdmin
            },
            {
                path: 'apply',
                name: 'apply',
                component: Apply,
            },
            {
                path: 'realtime',
                name: 'realtime',
                component: realtimeVue
            },
            {
                path: 'replay',
                name: 'replay',
                component: Replay
            },
            {
                path: 'logger',
                name: 'logger',
                component: Logger
            }
        ]
    }
];

const createRouter = () => {
    console.log("userMenus---", store.state.userMenus);
    // asyncRoutes.push(store.state.userMenus);
    const xRouter = new Router({
        routes: asyncRoutes,
    });
    return xRouter;
}

const router = createRouter();
export default router;
